package com.yitiao.designmodel.struct.flyweight;

import java.util.HashMap;
import java.util.Map;

/**
 * 享元工厂类
 */
public class FlyweightFactory {

    private final Map<String, Flyweight> flyweights = new HashMap<>();

    public Flyweight getFlyweight(String key) {
        return flyweights.getOrDefault(key,new ConcreteFlyweight(key));
    }
}
